<?php
/*
* ----------------------------------------------------------------------------------------------------
* OPTION CONFIG
* @Author Vuong Thanh
* ----------------------------------------------------------------------------------------------------
*/
/**
* This function be used for add theme options menu.
*/
function options_menu()
{
	$m = 'add_menu_page';
	$s = 'add_submenu_page';
	$m(THEME_NAME, THEME_NAME, 'administrator', 'option_general.php', 'tt_load_theme_pages', IMAGE_URI . '/favicon.ico', 58);
	$s('option_general.php', 'General', 'General', 'administrator', 'option_general.php', 'tt_load_theme_pages');
	$s('option_general.php', 'Header', 'Header', 'administrator', 'option_header.php', 'tt_load_theme_pages');
	$s('option_general.php', 'Footer', 'Footer', 'administrator', 'option_footer.php', 'tt_load_theme_pages');
	$s('option_general.php', 'Blog', 'Blog', 'administrator', 'option_blog.php', 'tt_load_theme_pages');
	$s('option_general.php', 'Portfolio', 'Portfolio', 'administrator', 'option_portfolio.php', 'tt_load_theme_pages');
	$s('option_general.php', 'Slideshow', 'Slideshow', 'administrator', 'option_slideshow.php', 'tt_load_theme_pages');
	$s('option_general.php', 'Testimonial', 'Testimonial', 'administrator', 'option_testimonial.php', 'tt_load_theme_pages');
	$s('option_general.php', 'Contact', 'Contact', 'administrator', 'option_contact.php', 'tt_load_theme_pages');
	$s('option_general.php', 'Font', 'Font', 'administrator', 'option_font.php', 'tt_load_theme_pages');
	$s('option_general.php', 'Style', 'Style', 'administrator', 'option_style.php', 'tt_load_theme_pages');
}

add_action('admin_menu', 'options_menu');



/**
* This function be used for load theme pages.
*/
function tt_load_theme_pages() 
{

	$page = include(API_DIR . '/admin_options/pages/' . $_GET['page']);

	if($page['auto'])
	{
		new theme_options_generator($page['name'],$page['options']);
	}

}



/**
* Loads the default options for admin pages.
*/

class tt_Options
{
	function tt_default_Options() {
		global $theme_options;
		$theme_options = array();
		$option_files = array(
			'option_general',
			'option_header',
			'option_portfolio',
			'option_footer',
			'option_contact',
			'option_font',
			'option_style',
			'option_blog',
			'option_slideshow',
			'option_testimonial',
			
		);
		foreach($option_files as $file){
			$page = include (API_DIR . '/admin_options/pages/' . $file.'.php');
			$theme_options[$page['name']] = array();
			foreach($page['options'] as $option) {
				if (isset($option['std'])) {
					$theme_options[$page['name']][$option['id']] = $option['std'];
				}
			}
			$theme_options[$page['name']] = array_merge((array) $theme_options[$page['name']], (array) get_option('theme_' .THEME_SLUG . '_' . $page['name']));
		}
	}
}
?>